<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="4" :xs="24">
        <my-dept-tree v-model="queryParams.deptId" @change="handleDeptChange" ref="deptTree"></my-dept-tree>
      </el-col>
      <el-col :span="20" :xs="24">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
          <el-form-item label="路线名称" prop="roadName">
            <el-input v-model="queryParams.roadName" placeholder="请输入路线名称" clearable @change="handleQuery" />
          </el-form-item>
          <el-form-item label="上报人" prop="createBy">
            <dept-user-select ref="deptUserSelect" :deptId="queryParams.deptId" v-model="queryParams.createBy" placeholder="请选择上报人"></dept-user-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['cases:troubleshootingTable:add']">新建</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="success" :disabled="commitDisabled" plain size="mini" @click="handleCommit" v-hasPermi="['cases:troubleshootingTable:add']">提交</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="warning" :disabled="cancelCommitDisabled" plain size="mini" @click="handleCancelCommit" v-hasPermi="['cases:troubleshootingTable:add']">取消提交</el-button>
          </el-col>
        </el-row>

        <el-table v-loading="loading" :row-style="rowStyle" :highlight-current-row="true" @row-click="handleRowClick" :data="tableData" @selection-change="handleSelectionChange">
          <el-table-column type="index" :index="(index)=>tableIndex(queryParams.pageSize,queryParams.pageNum,index)" label="序号" align="center" />
          <el-table-column label="路线名称" align="center" prop="roadName" width="150"/>
          <el-table-column label="上报人" align="center" prop="createUserName" width="150" />
          <el-table-column label="创建时间" align="center" prop="assignDate" width="160" />
          <el-table-column label="类型" align="center" prop="iTroubleshooting" width="150">
            <template slot-scope="scope">
              {{getCheckTypeName(scope.row.iTroubleshooting)  || "--"}}
            </template>
          </el-table-column>
          <el-table-column label="作业项目" align="center" prop="quantitativeTypeName" width="150" />
          <el-table-column label="位置桩号" align="center" prop="locationNum" width="150">
            <template slot-scope="scope">
              {{ scope.row.locationNum || "--"}}
            </template>
          </el-table-column>
          <el-table-column label="状态" align="center" prop="dataStatus" width="100">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.jl_data_status" :value="scope.row.dataStatus"></dict-tag>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button size="mini" type="text" icon="el-icon-view" @click="handleDetail(scope.row)">查看</el-button>
              <el-button size="mini" type="text" icon="el-icon-copy-document" @click="handleCopy(scope.row)">复制本条信息</el-button>
              <el-button size="mini" type="text" icon="el-icon-edit" :disabled="scope.row.dataStatus != '1' && scope.row.dataStatus != '4'" @click="handleUpdate(scope.row)" v-hasPermi="['cases:troubleshootingTable:edit']">修改</el-button>
              <el-button size="mini" type="text" icon="el-icon-delete" :disabled="scope.row.dataStatus != '1'" @click="handleDelete(scope.row)" v-hasPermi="['cases:troubleshootingTable:remove']">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
      </el-col>
    </el-row>
    <el-dialog :title="title" :close-on-click-modal="false" :visible.sync="open" width="800px" append-to-body :before-close="handleClose">
      <el-form ref="form" :model="form" :rules="rules" label-width="100px" size="mini">
        <div class="form-title">基本信息</div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="上报部门" prop="deptName">
              <el-input :disabled="true" v-model="form.deptName" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="录入人" prop="createUserName">
              <el-input :disabled="true" v-model="form.createUserName" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="路线名称" prop="roadName">
              <el-input v-model="form.roadName" placeholder="请输入路线名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="位置桩号" prop="locationNum">
              <el-input v-model="form.locationNum" placeholder="请输入位置桩号" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="排查方向" prop="troubleshootingDirection">
              <el-input v-model="form.troubleshootingDirection" placeholder="请输入排查方向" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="排查时间" prop="troubleshootingTime">
              <el-date-picker clearable v-model="form.troubleshootingTime" type="date" value-format="yyyy-MM-dd" placeholder="请选择排查时间" style="width:100%"></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <div class="form-title">工作明细</div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="项目类型" prop="taskType">
              <el-radio-group v-model="form.taskType"  @change="handleTaskTypeChange">
                <el-radio label="1">定额项目</el-radio>
                <el-radio label="2">定额外项目</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="类型" prop="iTroubleshooting">
              <common-check-type-select ref="iTroubleshootingTypeSelect" v-model="form.iTroubleshooting" :parentId="0" placeholder="请选择类型" @change="hanleITroubleshootingChange"></common-check-type-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="form.taskType == '1'">
            <el-form-item label="作业项目" prop="quantitativeTypeId">
              <maintain-work-project-select ref="quantitativeTypeSelect" :checkTypeId="form.iTroubleshooting" v-model="form.quantitativeTypeId" placeholder="请选择作业项目" @change="handleQuantitativeTypeChange"></maintain-work-project-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-else>
            <el-form-item label="作业项目" prop="beyondQuota">
              <el-input v-model="form.beyondQuota" placeholder="请输入作业项目" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="自有人员" prop="ownPersonnel">
              <dept-user-select placeholder="请选择自有人员" :multiple="true" v-model="form.ownPersonnel" :deptId="form.deptId"></dept-user-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="外包人数" prop="outSourceNum">
              <el-input-number :min="0" v-model="form.outSourceNum" placeholder="请输入外包人数" controls-position="right" style="width:180px"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="完成时间/天" prop="acceptanceDays">
              <el-input-number v-model="form.acceptanceDays" placeholder="请输入完成时间" controls-position="right" :precision="1" style="width:180px"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="完成工作量" prop="taskNum" >
              <el-input-number :min="0" :max="form.taskType=='1'?Infinity:8" v-model="form.taskNum" placeholder="请输入完成工作量" controls-position="right" :precision="1" style="width:180px"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="合格工作量" prop="qualifiedNum">
              <el-input-number :min="0"  v-model="form.qualifiedNum" placeholder="请输入合格工作量" controls-position="right" :precision="1" style="width:180px"/>
            </el-form-item>
          </el-col>
           <el-col :span="12">
            <el-form-item label="工作量单位" prop="numUnit">
              <dict-select dict="jl_case_unit" v-model="form.numUnit" placeholder="请选择工作量单位"></dict-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="材料使用量" prop="materialUsage">
              <el-input v-model="form.materialUsage" placeholder="请输入材料使用量" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="情况简单描述" prop="description">
              <el-input type="textarea" v-model="form.description" placeholder="请输入情况简单描述" />
            </el-form-item>
          </el-col>
        </el-row>
        <div class="form-title">施工照片</div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="施工前照片" prop="picIdsBegin">
              <image-upload v-model="form.picIdsBegin" :isShowTip="!isDisabled" :limit="100" :fileSize="1000" :isDisabled="isDisabled" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="施工中照片" prop="picIdsMiddle">
              <image-upload v-model="form.picIdsMiddle" :isShowTip="!isDisabled" :limit="100" :fileSize="1000" :isDisabled="isDisabled" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="施工后照片" prop="picIdsEnd">
              <image-upload v-model="form.picIdsEnd" :isShowTip="!isDisabled" :limit="100" :fileSize="1000" :isDisabled="isDisabled" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="审核人" prop="auditUserId">
              <el-input :disabled="true" v-model="form.auditUserName" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm" v-if="!isDisabled">保 存</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <trouble-shooting-detail-dialog ref="troubleShootingDetailDialog" title="工作上报--详情"></trouble-shooting-detail-dialog>
  </div>
</template>

<script>
import {
  listTroubleShooting,
  getTroubleShooting,
  delTroubleShooting,
  addTroubleShooting,
  updateTroubleShooting,
  getAuditUser
} from "@/api/cases/troubleShooting";
import CommonCheckTypeSelect from '../../../components/Select/CommonCheckTypeSelect.vue';
import DictSelect from '../../../components/Select/DictSelect.vue';
import DeptUserSelect from '../../../components/Select/DeptUserSelect.vue';
import { listCommonCheckType } from '@/api/cases/commonCheckType'
import TroubleShootingDetailDialog from '@/components/Dialog/troubleShootingDetailDialog.vue';
import DeptTree from '../../../components/Tree/DeptTree.vue';

import { mapGetters } from 'vuex';
import MaintainWorkProjectSelect from '../../../components/Select/MaintainWorkProjectSelect.vue';
import MyDeptTree from '../../../components/Tree/MyDeptTree.vue';
let rules = {
  roadName: [
    { required: true, message: "路线名称不能为空", trigger: "blur" },
  ],
  locationNum: [
    { required: true, message: "位置桩号不能为空", trigger: "blur" },
  ],
  troubleshootingTime: [
    { required: true, message: "排查时间不能为空", trigger: "change" },
  ],
  taskType: [
    { required: true, message: "项目类型不能为空", trigger: "change" },
  ],
  taskNum: [
    { required: true, message: "完成工作量不能为空", trigger: "change" },
  ],
  picIdsEnd: [
    { required: true, message: "施工后照片不能为空", trigger: "change" },
  ],
  numUnit:[
    { required: true, message: "工作量单位不能为空", trigger: "change" },
  ],
  qualifiedNum: [
    { required: true, message: "合格工作量不能为空", trigger: "blur" },
  ],
  acceptanceDays:[
    { required: true, message: "完成时间不能为空", trigger: "blur" },
  ],
  auditUserId: [
    { required: true, message: "审核人不能为空", trigger: "blur" },
  ],
};
export default {
  name: "troubleShooting",
  dicts: ["jl_cases_damage_level", "jl_cases_repair_method", "jl_data_status"],
  components: { DictSelect, CommonCheckTypeSelect, DictSelect, DeptUserSelect, TroubleShootingDetailDialog, DeptTree,MaintainWorkProjectSelect, MyDeptTree },
  data() {
    return {
      // 禁用表单
      isDisabled: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      //选中行
      selection: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 工作上报管理表格数据
      tableData: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        roadName: void 0,
        deptId: void 0,
        createBy: void 0
      },
      rules,
      // 表单参数
      form: {
        id: void 0,
        roadName: void 0,//路线名称
        locationNum: void 0,//位置桩号
        troubleshootingDirection: void 0,//排查方向
        troubleshootingTime: void 0,//排查时间
        taskType: void 0,//类型
        beyondQuota: void 0,//额定外工作
        iTroubleshooting: void 0,//类型
        ownPersonnel: void 0,//自有人员
        outSourceNum: 0,//外包人数
        taskNum:void 0,//完成工作量
        qualifiedNum: void 0,//合格工作量
        unqualifiedNum: void 0,//不合格工作量
        numUnit: void 0,//工作量单位
        materialUsage: void 0,//材料使用量
        description: void 0,//描述
        picIdsBegin: void 0,//施工前照片
        picIdsMiddle: void 0,//施工中照片
        picIdsEnd: void 0,//施工后照片
        auditUserId: void 0,//审核人id
        auditUserName: void 0,//审核人名称
        deptId: void 0,//排查部门id
        deptName: void 0,//排查部门名称
        userId: void 0,//录入人
        createUserName: void 0,//录入人
      },
      checkTypes: [],//检查类型
    };
  },
  async created() {
    await this.getCheckTypes();
  },
  computed: {
    ...mapGetters(["userId", "nickName", "deptId", "deptName"]),
    commitDisabled() {
      if (this.selection.length > 0) {
        return this.selection.some((item) => {
          return item.dataStatus != 1 && item.dataStatus != 4
        })
      } else {
        return true
      }
    },
    cancelCommitDisabled() {
      if (this.selection.length > 0) {
        return this.selection.some((item) => {
          return item.dataStatus != 2
        })
      } else {
        return true
      }
    },
  },
  watch: {
    "form.taskType": {
      handler(value) {
        if (value == 1) {
          let rules1 = {
            iTroubleshooting: [
              { required: true, message: "类型不能为空", trigger: "change" },
            ],
            quantitativeTypeId: [
              { required: true, message: "作业项目不能为空", trigger: "change" },
            ],
          }
          Object.assign(this.rules, rules1)
        } else {
          let rules2 = {
            beyondQuota: [
              { required: true, message: "作业项目不能为空", trigger: "blur" },
            ],
            taskNum: [
              { required: true, message: "完成工作量不能为空", trigger: "blur" },
            ],
          }
          Object.assign(this.rules, rules2)
        }
        console.log("this.form",this.form)
      },
      deep: true

    }
  },
  methods: {
    /** 查询工作上报管理列表 */
    getList() {
      this.loading = true;
      listTroubleShooting(this.queryParams).then((response) => {
        this.tableData = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 表单重置
    reset() {
      this.form = {
        id: void 0,
        roadName: void 0,//路线名称
        locationNum: void 0,//位置桩号
        troubleshootingDirection: void 0,//排查方向
        troubleshootingTime: void 0,//排查时间
        taskType: '1',//类型
        beyondQuota: void 0,//额定外工作
        iTroubleshooting: void 0,//类型
        ownPersonnel: void 0,//自有人员
        outSourceNum: 0,//外包人数
        taskNum:void 0,//完成工作量
        qualifiedNum: void 0,//合格工作量
        unqualifiedNum: void 0,//不合格工作量
        numUnit: void 0,//工作量单位
        materialUsage: void 0,//材料使用量
        description: void 0,//描述
        picIdsBegin: void 0,//施工前照片
        picIdsMiddle: void 0,//施工中照片
        picIdsEnd: void 0,//施工后照片
        auditUserId: void 0,//审核人id
        auditUserName: void 0,//审核人名称
        deptId: void 0,//排查部门id
        deptName: void 0,//排查部门名称
        userId: void 0,//录入人
        createUserName: void 0,//录入人
      };
      this.resetForm("form");
    },

    /**
     * 项目类型变化时
     */
    handleTaskTypeChange(value){
      if(value == 2){
        this.form.taskNum = 8;
        this.form.numUnit = "19";
      }else{
        this.form.taskNum = void 0;
        this.form.numUnit = void 0;
      }
    },
    /**
     * 排查类型变化时
     */
    handleQuantitativeTypeChange(value){
      if(value){
        let quantitativeType = this.$refs.quantitativeTypeSelect.getQuantitativeTypeById(this.form.quantitativeTypeId);
        this.form.taskNum = quantitativeType.ratedNum;
        this.form.numUnit = quantitativeType.ratedUnit;
      }
    },
    /**
     * 点击树
     */
    handleDeptChange(){
      this.$refs.deptUserSelect.clear();
      this.handleQuery();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.selection = selection
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    async handleAdd() {
      this.reset();
      this.form.deptId = this.queryParams.deptId;
      let deptName = this.$refs.deptTree.getDeptNameById(this.form.deptId);
      this.form.deptName = deptName;
      this.form.createUserName = this.nickName;
      this.form.userId = this.userId;
      await this.getAuditUser();
      this.isDisabled = false;
      this.open = true;
      this.title = "工作上报-新增";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.isDisabled = false;
      const id = row.id || this.ids;
      getTroubleShooting(id).then((response) => {
        this.form = response.data;
        console.log("form.ownPersonnel",this.form.ownPersonnel)
        this.open = true;
        this.title = "工作上报--修改";
      });
    },
    /** 查看 */
    handleDetail(row) {
      const id = row.id || this.ids;
      getTroubleShooting(id).then((response) => {
        let form = response.data;
        this.$refs.troubleShootingDetailDialog.open(form)
      });
    },
    /**
     * 复制
     */
    handleCopy(row){
      const id = row.id || this.ids;
      getTroubleShooting(id).then(async (response) => {
        this.reset();
        this.form = response.data;
        this.form.id = void 0;
        this.form.ownPersonnel = void 0;
        this.form.outSourceNum = void 0;
        this.form.beyondQuota = void 0;
        this.form.quantitativeTypeId = void 0;
        this.form.picIdsBegin = void 0;
        this.form.picIdsMiddle = void 0;
        this.form.picIdsEnd = void 0;
        this.form.deptId = this.queryParams.deptId;
        let deptName = this.$refs.deptTree.getDeptNameById(this.form.deptId);
        this.form.deptName = deptName;
        this.form.createUserName = this.nickName;
        this.form.userId = this.userId;
        await this.getAuditUser();
        this.isDisabled = false;
        this.open = true;
        this.title = "工作上报-新增";
      });
    },
    /**
     * 获取审核人
     */
    getAuditUser() {
      return new Promise((resolve,reject)=>{
        getAuditUser(this.form.deptId).then(({ code, data, msg }) => {
          if (code == 200) {
            if(data){
              this.form.auditUserId = data.userId;
              this.form.auditUserName = data.nickName + "（工区主任）";
              resolve();
            }else{
              this.$modal.msgError("该部门无对应审批人")
              reject();
            }
          } else {
            this.$modal.msgError(msg)
            reject();
          }
        })
      })
    },
    /** 提交按钮 */
    submitForm() {
      this.form.locationPileNumber = this.form.locationPileNumberBegin + this.form.locationPileNumberEnd
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (Number(this.form.taskType)==1 && Number(this.form.qualifiedNum) > Number(this.form.taskNum)) {
            this.$modal.msgError("请确认合格工作量是否填写正确");
            return;
          }
          if ((this.form.ownPersonnel && this.form.ownPersonnel.length > 0) || this.form.outSourceNum > 0) {
            if (this.form.id != null) {
              updateTroubleShooting(this.form).then(({ code, data, msg }) => {
                if (code == 200) {
                  this.$modal.msgSuccess("修改成功");
                  this.handleClose();
                  this.getList();
                } else {
                  this.$modal.msgError(msg);
                }
              });
            } else {
              addTroubleShooting(this.form).then(({ code, data, msg }) => {
                if (code == 200) {
                  this.$modal.msgSuccess("新增成功");
                  this.handleClose()
                  this.getList();
                } else {
                  this.$modal.msgError(msg);
                }
              });
            }
          } else {
            this.$modal.msg("请选择自有人员或填写外包人数");
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除此工作上报的数据项？')
        .then(function () {
          delTroubleShooting(ids).then(({ code, data, msg }) => {
            if (code == 200) {
              this.$modal.msgSuccess("删除成功");
              this.getList();
            } else {
              this.$modal.msgError(msg);
            }
          });;
        });
    },
    /**
     * 点击行
     */
    handleRowClick(row, column, event) {
      this.selection = [row];
    },
    /**
     * 提交
     */
    handleCommit() {
      //将待提交1的改成待审核2
      this.$confirm("是否确定提交此工作记录?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        let params = Object.assign({}, this.selection[0], { dataStatus: 2 });
        updateTroubleShooting(params).then(({ code, data, msg }) => {
          if (code == 200) {
            this.$modal.msgSuccess("提交成功");
            this.getList();
          } else {
            this.$modal.msgError(msg);
          }
        })
      })
    },
    /**
     * 取消提交
     */
    handleCancelCommit() {
      //将待审核2的改成待提交1
      this.$confirm("是否确定取消提交此工作记录?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        let params = Object.assign({}, this.selection[0], { dataStatus: 1 });
        updateTroubleShooting(params).then(({ code, data, msg }) => {
          if (code == 200) {
            this.$modal.msgSuccess("取消提交成功");
            this.getList();
          } else {
            this.$modal.msgError(msg);
          }
        })
      })
    },
    /**
     * 类型发生变化时
     */
    hanleITroubleshootingChange(){
      this.$nextTick(()=>{
        this.$refs.quantitativeTypeSelect?.clear();
      })
    },
    /**
     * 行样式
     */
    rowStyle() {
      return {
        "cursor": "pointer"
      }
    },
    /**
     * 获取类型
     */
    getCheckTypes() {
      let params = {
        status: 0,
        delFlag: 0
      }
      return new Promise((resolve, reject) => {
        listCommonCheckType(params).then(res => {
          this.checkTypes = res.data;
          resolve()
        }).catch(() => {
          this.checkTypes = [];
          reject()
        })
      })
    },
    /**
     * 获取检查的名称
     */
    getCheckTypeName(checkType) {
      let index = this.checkTypes.findIndex((item) => {
        return item.id == checkType;
      })
      if (index > -1) {
        return this.checkTypes[index].checkTypeName
      } else {
        return ""
      }
    },
    /**
     * 处理关闭
     */
    handleClose() {
      this.cancel();
    },
    /**
     * 隐藏
     */
    cancel() {
      this.open = false;
    },
  },
};
</script>
<style lang="scss" scoped>
.form-title {
  padding: 2px 0;
  border-bottom: 1px solid #eee;
  margin-bottom: 10px;
}
.input-sperator {
  margin-right: 10px;
  margin-left: 10px;
  padding-bottom: 18px;
  line-height: 29px;
}
</style>
